package com.day05;

//一个简单登录注册案例
import java.util.Scanner;

public class login {
    //new一个对象，从键盘输入
    static Scanner scanner = new Scanner(System.in);
    static String username = new String();
    static String password = new String();
    //主函数main入口
    public static void main(String[] args){
        //从控制台循环打印输出一个菜单
        while (true) {
            System.out.println("************菜单************");
            System.out.println("1.注册");
            System.out.println("2.登录");
            System.out.println("3.退出");
            System.out.println("***************************");
            int id = scanner.nextInt();
           //根据所输入不同的数字对应不同功能
            switch (id){
                case 1:
                    sxr1();
                    break;
                case 2:
                    sxr2();
                    break;
            }
            if (id == 3){
                    break;
            }
        }
        System.out.println("已成功退出！！！");

    }
     //从键盘依次获取输入数据
    public static void sxr1(){
        System.out.println("请输入用户名");
        username = scanner.next();
        System.out.println("请输入密码");
        password = scanner.next();
        System.out.println("注册成功");
    }

     //从键盘依次获取输入数据
    public static void sxr2(){
        System.out.println("请输入用户名");
        String user = scanner.next();
        System.out.println("请输入密码");
        String pss = scanner.next();
        if (username.equals(user) && password.equals(pss)){
            System.out.println("登录成功");
        }else {
            System.out.println("账户或密码错误");
        }
    }

}
